package cn.hackcloud.designpattern.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyFactory {
	private Object target;

	public ProxyFactory(Object target) {
		super();
		this.target = target;
	}

	public Object getProxyInstance() {

		Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(),
				new InvocationHandler() {

					@Override
					public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
						Object object = method.invoke(proxy, args);
						return object;
					}
				});
		return target;

	}
}
